package com.intxt.bbs.service;

import java.util.List;

import com.intxt.bbs.model.Link;
import com.jfinal.log.Logger;
import com.jfinal.plugin.activerecord.TableMapping;

public class LinkService {
	private Logger log = Logger.getLogger(LinkService.class);
	
	public Link save(Link link){
		link.save();
		return link;
	}
	
/*	public List<Link> findAllLink(String userId){
		return Link.DAO.find("select * from "+TableMapping.me().getTable(Link.class).getName()+" where user_id = '"+userId+"' or user_id ='system' order by weight");
	}*/
	
	public List<Link> findUserLink(String userId){
		return Link.DAO.find("select * from "+TableMapping.me().getTable(Link.class).getName()+" where user_id = '"+userId+"' order by weight");
	}
	
	public List<Link> findSystemLink(){
		return Link.DAO.find("select * from "+TableMapping.me().getTable(Link.class).getName()+" where user_id = 'system' order by weight");
	}
	
	public Link updae(Link link){
		link.update();
		return link;
	}
	
	public boolean del(Link link){
		return link.delete();
	}
	
}
